﻿@*Original from KendoUI examples*@

@{
    var viewPath = ((BuildManagerCompiledView)ViewContext.View).ViewPath;
    var viewSource = System.IO.File.ReadAllText(Server.MapPath(viewPath));

    var routeData = ViewContext.RouteData;
    var suiteName = routeData.GetRequiredString("suite");
    var controllerName = routeData.GetRequiredString("controller");
    var viewName = routeData.GetRequiredString("action");
    var controllerPath = Server.MapPath("~/Controllers/" + suiteName + "/" + controllerName + "/" + viewName + "Controller.cs");

    string controllerSource = "";
    if (System.IO.File.Exists(controllerPath))
    {
        controllerSource = System.IO.File.ReadAllText(controllerPath);
    }
}
<div class="source">
    Source:
    <a href="#" class="offline-button view selected">View</a>
    <a href="#" class="offline-button controller">Controller</a>
    <div class="code">
        <pre class="prettyprint view">@viewSource</pre>
        <pre class="prettyprint controller">@controllerSource</pre>
    </div>
</div>
<script>
    $(function () {
        prettyPrint();

        $(".source a").click(function (e) {
            var showView = $(this).is(".view");

            $(".source .code")
                .find(".view").toggle(showView).end()
                .find(".controller").toggle(!showView);

            $(".source a").toggleClass("selected");

            e.preventDefault();
        });
    });
</script>